from model.uml_element import UmlElement


class UmlValue(UmlElement):
    def __init__(self) -> None:
        super().__init__()
        self.name: str = ""
        self.type: str = ""
        self.instance: str = ""
        self.value: str = ""

    def to_json(self) -> dict[str, object]:
        json: dict = super().to_json()
        json["name"] = self.name
        json["type"] = self.type
        json["instance"] = self.instance
        json["value"] = self.value

        return json

    def from_json(self, json: dict):
        if json is None:
            return
        
        super().from_json(json)
        self.type = json.get("type", "")
        self.instance = json.get("instance", "")
        self.value = json.get("value", "")
